﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Fashion Girls</title>
<link href="/media/css/albums.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="/media/js/jquery.cookie.js"></script>
<link rel="stylesheet" href="/media/jquery-ui/sunny/jquery-ui-1.7.2.custom.css" type="text/css" media="print, projection, screen">

<style type="text/css">

</style>

<script type="text/javascript">
function changeThumbnailImages(images){
    images.each(
        function( intIndex ){
            var img_url = $(this).attr('src');
            if(img_url.search(/http\:\/\/lh\d\.ggpht\.com\//)==0){
                img_url = img_url.replace(/s64-c/, "s144-c");
                $(this).attr('src', img_url);
            } else {
                img_url = img_url.replace(/_s\./, "_m.");
                $(this).attr('src', img_url);
                //$(this).attr('height', '144');
                //$(this).css('height', '144px');
            }
        }
    );
}

function addStyle(cssString) {
    //alert(cssString);
    var headTag = document.getElementsByTagName("head");

    var styleElement = document.createElement("style");
    styleElement.setAttribute("type", "text/css");
    if (styleElement.styleSheet) {// For IE
        styleElement.styleSheet.cssText = cssString;
    } else {
        var cssTextNode = document.createTextNode(cssString)
        styleElement.appendChild(cssTextNode);
    }

    if (headTag.length > 0) {
		headTag[0].appendChild(styleElement);
    } else {
        var bodyTag = document.getElementsByTagName("body");
        if (bodyTag.length > 0) {
            bodyTag[0].insertBefore(styleElement, bodyTag[0].firstChild);
        } else {
            document.documentElement.appendChild(styleElement);
        }
    }
}

function hideThumbButtonOfAlbumId(albumid){
    $('.thumbup[albumid="'+albumid+'"]').each(
        function(idx) {
            $(this).css("display", "none");
        }
    );
    $('.thumbdown[albumid="'+albumid+'"]').each(
        function(idx) {
            $(this).css("display", "none");
        }
    );

    var style = '\n.thumbup[albumid="'+albumid+'"] {display:none;}\n.thumbdown[albumid="'+albumid+'"] {display:none;}\n';
    addStyle(style);
}

function setThumbButtonHideForAlbumIds(albumids) {
    for(var i=0; i<albumids.length; i++) {
        var albumid = albumids[i];
        if($.cookie(albumid)) {
            hideThumbButtonOfAlbumId(albumid);
            $.cookie(albumid, '1', { expires: 365 });
        }
    }
}

{% ifequal user_type "admin" %}
function setAlbumHideWithId(albumid, hide) {
    
    $(".hide[albumid='"+albumid+"']").each(
        function(idx) {
            $(this).attr('hide', hide+"");
        }
    );
    
    if(hide==1) {
        $("li[albumid='"+albumid+"']").each(
            function(idx) {
                //$(this).css("opacity", "0.3");
                //$(this).css("filter", "alpha(opacity=30)");
                $(this).fadeTo("slow", 0.3);
            }
        );
        var style = '\nli[albumid="'+albumid+'"] {opacity:0.3;filter:alpha(opacity=30);}\n';
        addStyle(style);
    } else {
        $("li[albumid='"+albumid+"']").each(
            function(idx) {
                //$(this).css("opacity", "1.0");
                //$(this).css("filter", "alpha(opacity=100)");
                $(this).fadeTo("slow", 1.0);
            }
        );
        var style = '\nli[albumid="'+albumid+'"] {opacity:1.0;filter:alpha(opacity=100);}\n';
        addStyle(style);
    }
}
{% endifequal %}

$(function(){
    $("#tabs").tabs(
        {
            cache: true,
            ajaxOptions: { async: true },
            load: function(event, ui) {
                changeThumbnailImages($(event.target).find(".cover_img"));
            }
        }
    );
    
    {% ifequal user_type "user" %}
    var albumids=new Array("0"{% for album in albums %},"{{ album.shareid }}"{% endfor %});
    setThumbButtonHideForAlbumIds(albumids);
    {% endifequal %}
    
    {% ifequal user_type "admin" %}
    {% for album in albums %}
    {% ifequal album.hide 1 %}
    setAlbumHideWithId('{{ album.shareid }}', {{ album.hide }});
    {% endifequal %}
    {% endfor %}

    var max_editor_score = {{max_editor_score}};
    var min_editor_score = {{min_editor_score}};
    
    {% endifequal %}
    
    changeThumbnailImages($(".cover_img"));

    $(".thumbup").live("click",
        function (e) {
            var albumid = $(this).attr('albumid');

            {% ifequal user_type "user" %}
            hideThumbButtonOfAlbumId(albumid);
            if($.cookie(albumid)) {
                return;
            }
            $.cookie(albumid, '1', { expires: 365 });
            {% endifequal %}
            
            //$("#album_score_"+albumid).html(parseInt($("#album_score_"+albumid).html())+1);
            $(".albumscore[albumid='"+albumid+"']").each(
                function(idx) {
                    $(this).html(parseInt($(this).html())+1);
                }
            );
            var url = '/thumbup/{{user_type}}/'+albumid+'/';
            $.get(url,
                function(data){
                    //alert(data);
                    //alert('OK');
                    var array = data.split(':');

                    {% ifequal user_type "admin" %}
                    if(parseInt(array[1])>max_editor_score){
                        alert('已经达到最高分');
                        max_editor_score = parseInt(array[1]);
                    }
                    {% endifequal %}

                    //$("#album_score_"+array[0]).html(array[1]);
                    $(".albumscore[albumid='"+array[0]+"']").each(
                        function(idx) {
                            $(this).html(array[1]);
                        }
                    );
                }
            );
        }
    );

    $(".thumbdown").live("click",
        function (e) {
            var albumid = $(this).attr('albumid');
            
            {% ifequal user_type "user" %}
            hideThumbButtonOfAlbumId(albumid);

            if($.cookie(albumid)) {
                alert("您已对此相册评过分");
                return;
            }
            
            $.cookie(albumid, '1', { expires: 365 });
            {% endifequal %}
            
            //$("#album_score_"+albumid).html(parseInt($("#album_score_"+albumid).html())-1);
            $(".albumscore[albumid='"+albumid+"']").each(
                function(idx) {
                    $(this).html(parseInt($(this).html())-1);
                }
            );
            var url = '/thumbdown/{{user_type}}/'+albumid+'/';
            $.get(url,
                function(data){
                    //alert(data);
                    //alert('OK');
                    var array = data.split(':');

                    {% ifequal user_type "admin" %}
                    if(parseInt(array[1])<min_editor_score){
                        alert('已经达到最低分');
                        min_editor_score = parseInt(array[1]);
                    }
                    {% endifequal %}

                    //$("#album_score_"+array[0]).html(array[1]);
                    $(".albumscore[albumid='"+array[0]+"']").each(
                        function(idx) {
                            $(this).html(array[1]);
                        }
                    );
                }
            );
        }
    );
    
    {% ifequal user_type "admin" %}
    $(".hide").live("click",
        function (e) {
            var albumid = $(this).attr('albumid');
            
            var hide = $(this).attr('hide');
            setAlbumHideWithId(albumid, 1-parseInt(hide));

            var url = '/hide/'+albumid+'/';
            $.get(url,
                function(data){
                    var array = data.split(':');
                    if(parseInt(array[1])==1){
                        //alert("hide");
                        setAlbumHideWithId(albumid, 1);
                    } else {
                        //alert("show");
                        setAlbumHideWithId(albumid, 0);
                    }
                }
            );
        }
    );
    
    $(".delete").live("click",
        function (e) {
            var answer = confirm("此操作不可恢复，确定删除这个相册?");
            if(answer) {
                var albumid = $(this).attr('albumid');
                
                var url = '/delete/'+albumid+'/';
                $.get(url,
                    function(data){
                        var array = data.split(':');
                        if(parseInt(array[1])==1){
                            $("li[albumid='"+albumid+"']").each(
                                function(idx) {
                                    $(this).fadeTo(1000, 0.0, 
                                        function () {
                                            $(this).css("display", "none");
                                            var style = '\nli[albumid="'+albumid+'"] {display:none;}\n';
                                            addStyle(style);
                                        }
                                    );
                                }
                            );
                            //var style = '\nli[albumid="'+albumid+'"] {display:none;}\n';
                            //addStyle(style);
                        }
                    }
                );
            }
        }
    );
    {% endifequal %}

    $(".albumurl").live("click",
        function (e) {
            var albumid = $(this).attr('albumid');
            var url = '/albumpreview/'+albumid+'/';
            $.get(url);
        }
    );

});

</script>
</head>
<body>
<div id="main">

<h2><a href="/?hl={{hl}}">相册列表</a> | <a href="/picasa/?hl={{hl}}">添加相册</a> | <a href="http://fashiongirls.appwill.com/download">iPhone App下载</a> | <span style="color:blue;font-weight:bold;">相册更新源：</span><span style="color:red;font-weight:bold;">http://fashion-girls.appspot.com/sources</span> | <a href="/?hl=en">English</a></h2>

<div style="border:1px dashed red;margin:5px 30px 5px 30px;padding:10px;font-size:10pt;font-weight:bold;">
    本站源代码: <a href='http://code.google.com/p/fashion-girls/'>http://code.google.com/p/fashion-girls/</a><br/>
    讨论区: <a href='http://groups.google.com/group/fashion-girls-iphone'>http://groups.google.com/group/fashion-girls-iphone</a><br/>
    官方主页: <a href='http://fashiongirls.appwill.com/'>http://fashiongirls.appwill.com/</a><br/>
    Email地址: <a href='mailto:support@appwill.com'>support@appwill.com</a><br/>
</div>

<div id="tabs">
    <ul>
        <li><a href="#tabs-1">编辑推荐</a></li>
        <li><a href="/?order=time">最新分享</a></li>
        <li><a href="/?order=score">评价排行</a></li>
        <li><a href="/?order=download">下载排行</a></li>
        <li><a href="/?order=preview">点击排行</a></li>
    </ul>
    <div id="tabs-1">
        {% block albums %}{% include "albums.html" %}{% endblock %}
    </div>
</div>

<div style="margin-top:30px;">
<a href="{{admin_url}}">{{admin_text}}</a>
</div>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-9726605-4");
pageTracker._trackPageview();
} catch(err) {}</script>
</div>
</body>
</html>